//
//  RegisterViewController.m
//  Pacific_Computer
//
//  Created by 范琦 on 14-12-17.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "RegisterViewController.h"
#import "UIColor+AddColor.h"
#import "WBSDKCommentButton.h"
#import "WBSDKRelationshipButton.h"
#import "WeiboSDK.h"

#define KAppKey         @"4266276295"
#define KRedirectURI    @"https://api.weibo.com/oauth2/default.html"

@interface RegisterViewController ()
{
    WBSDKRelationshipButtonState *relationshipButton;
    WBSDKCommentButton *commentButton;

    
}


@end

@implementation RegisterViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
        NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
        [center addObserver:self selector:@selector(receiveNotifica:) name:@"kuaipao" object:nil];
        
    }
    return self;
}


- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [super dealloc];
}

- (void)receiveNotifica:(NSNotificationCenter *)center
{
    [self.navigationController popToRootViewControllerAnimated:YES];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationItem.title = @"登入";
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    UIImage *image = [UIImage imageNamed:@"jilu.jpg"];
    imageView.image = image;
    [self.view addSubview:imageView];
    [imageView release];
    
    
    UIImageView *oneImage = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 2 / 5, self.view.bounds.size.height * 22.48 / 100, self.view.bounds.size.width / 5, self.view.bounds.size.height * 11.24 / 100)];
    oneImage.backgroundColor = [UIColor hongse];
    oneImage.layer.cornerRadius = oneImage.frame.size.width / 2;
    [self.view addSubview:oneImage];
    [oneImage release];
    
    
    
    UIImageView *akbImage = [[UIImageView alloc] initWithFrame:CGRectMake(oneImage.bounds.size.width * 4 / 100, oneImage.bounds.size.height * 4 / 100, oneImage.bounds.size.width * 92 / 100, oneImage.bounds.size.height * 92 / 100)];
    akbImage.backgroundColor = [UIColor whiteColor];
    akbImage.layer.cornerRadius = (oneImage.bounds.size.height * 86.66 / 100)/2;
    [oneImage addSubview:akbImage];
    [akbImage release];
    
    //
    UIImageView *NameImage = [[UIImageView alloc] initWithFrame:CGRectMake(oneImage.bounds.size.width * 15 / 100, oneImage.bounds.size.height * 15 / 100, oneImage.bounds.size.width * 70 / 100, oneImage.bounds.size.height * 70 / 100)];
    [oneImage addSubview:NameImage];
    NameImage.layer.cornerRadius = NameImage.bounds.size.height/2;
     UIImage *usimage = [UIImage imageNamed:@"User.png"];
    NameImage.image = usimage;
    NameImage.backgroundColor = [UIColor clearColor];
    NameImage.clipsToBounds = YES;
    [NameImage release];
    
    
       // UIImageView *UserImage = [[UIImageView alloc] initWithFrame:CGRectMake(sImage.bounds.size.width *15 / 100, sImage.bounds.size.height * 11.2 / 100, sImage.bounds.size.width - (sImage.bounds.size.width * 32.2 / 100), sImage.bounds.size.height - (sImage.bounds.size.height * 32.2 / 100))];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 26.66 / 100, self.view.bounds.size.height * 34 / 100, self.view.bounds.size.width * 46.66 / 100, self.view.bounds.size.height * 3.74 / 100)];
    label.text = @"未登入";
    label.font = [UIFont systemFontOfSize:14];
    label.textAlignment = 1;
    label.textColor = [UIColor hongse];
    [self.view addSubview:label];
    [label release];
    
//    UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 26.66 / 100, self.view.bounds.size.height * 39 / 100, self.view.bounds.size.width * 46.66 / 100, self.view.bounds.size.height * 3.74 / 100)];
//    label1.text = @"登入后分享更快捷";
//    label1.font = [UIFont systemFontOfSize:16];
//    label1.textAlignment = 1;
//    label1.textColor = [UIColor hongse];
//    [self.view addSubview:label1];
//    [label1 release];
    
    
    //==========================================
    //新浪登入
    UIView *xlView = [[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 13.33 / 100, self.view.bounds.size.height * 45 / 100, self.view.bounds.size.width * 73.33 / 100, self.view.bounds.size.height * 7 / 100)];
    xlView.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:xlView];
    xlView.layer.cornerRadius = 10;
    [xlView release];
    
    UIImageView * xlImage = [[UIImageView alloc] initWithFrame:CGRectMake(xlView.bounds.size.width / 3, xlView.bounds.size.height * 17 / 100, xlView.bounds.size.width / 8, xlView.bounds.size.height * 60 / 100)];
    [xlView addSubview:xlImage];
    UIImage * imageOne = [UIImage imageNamed:@"xinlang.png"];
    xlImage.image = imageOne;
    [xlImage retain];
    
    UILabel *xlLabel = [[UILabel alloc] initWithFrame:CGRectMake(xlView.bounds.size.width *28 / 100, xlView.bounds.size.height * 30 / 100, xlView.bounds.size.width * 2 / 3, xlView.bounds.size.height * 40 / 100)];
    xlLabel.text = @"微博登入";
    xlLabel.font = [UIFont systemFontOfSize:15];
    xlLabel.textAlignment = 1;
    xlLabel.textColor = [UIColor hongse];
    [xlView addSubview:xlLabel];
    [xlLabel release];
    
    UITapGestureRecognizer *xltap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(xltapAction:)];
    [xlView addGestureRecognizer:xltap];
    [xltap release];
    
    
    
    
    
}

- (void)xltapAction:(UITapGestureRecognizer *)tap
{
    
    
    
    
    
    
    WBAuthorizeRequest *request = [WBAuthorizeRequest request];
    request.redirectURI = KRedirectURI;
    request.scope = @"all";
    request.userInfo = @{@"SSO_From": @"RegisterViewController",
                         @"Other_Info_1": [NSNumber numberWithInt:123],
                         @"Other_Info_2": @[@"obj1", @"obj2"],
                         @"Other_Info_3": @{@"key1": @"obj1", @"key2": @"obj2"}};
    
    [WeiboSDK sendRequest:request];
    
}






- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
